// 本地 cookie 存储的 token 的 key
import Cookies from 'js-cookie'
import website from '@/config/website'
console.log(website, '看看');

// q: 下面这行diamante是什么意思
// a: 用于区分不同的项目，防止不同项目的token冲突

const TokenKey = website.key + '-token'
console.log(TokenKey,'看看');
const RefreshTokenKey = website.key + '-refresh-token' 
 // 实现无感刷新token ===>  https://juejin.cn/post/7170278285274775560#heading-10
export function getToken () {
    return Cookies.get(TokenKey)
}

export function setToken (token) {
    return Cookies.set(TokenKey, token)
}

export function getRefreshToken () {
    return Cookies.get(RefreshTokenKey)
}

export function setRefreshToken (token) {
    return Cookies.set(RefreshTokenKey, token)
}

export function removeToken () {
    return Cookies.remove(TokenKey)
}

export function removeRefreshToken () {
    return Cookies.remove(RefreshTokenKey)
}